package com.com.corejavalearnings.generics.designpattern.strategy;

/**
 * Created by pankaj on 7/26/15.
 */
public interface TaxStrategy<P extends TaxPayer>
{
    long compute (P payer);
}


class DefaultTaxStrategy<P extends TaxPayer> implements TaxStrategy<P>
{
    private static final double RATE = 0.40;
    @Override
    public long compute(P payer) {
        return Math.round(payer.getIncome() * RATE);
    }
}

class TrustTaxStrategy extends DefaultTaxStrategy<Trust>
{
    @Override
    public long compute(Trust trust) {
        return trust.isNonProfit() ? 0 : super.compute(trust);
    }
}
